package cn.itcast.tools.redis;

//import redis.clients.jedis.HostAndPort;
//import redis.clients.jedis.JedisCluster;
//import redis.clients.jedis.JedisPool;
//import redis.clients.jedis.JedisPoolConfig;
//import java.util.HashSet;
//import java.util.Set;
//
////import com.google.common.reflect.TypeToken;
//
//public class redis_hk_test {
//
//    JedisPoolConfig config = null;
//    JedisPool pool = null;
//    //Jedis jedis = null; //单节点模式
//    JedisCluster jedis = null; //集群模式
//
//    public static final double sim = 0.7;
//    public static final double chatLen = 3;
//
//    public redis_hk_test(String modelName, String modelConfig) {
//        System.out.println("JVM: modelName: " + modelName);
//        System.out.println("JVM: modelConfig: " + modelConfig);
//    }
//
//    public void Load() {
//        System.out.println("JVM: No Model To Load!");
//        try {
//            config = new JedisPoolConfig();
//            //最大空闲连接数，需自行评估，不超过Redis实例的最大连接数
//            config.setMaxIdle(200);
//            //最大连接数，需自行评估，不超过Redis实例的最大连接数
//            config.setMaxTotal(1000);
//            config.setTestOnBorrow(true);
//            config.setTestOnReturn(true);
//            config.setTestWhileIdle(true);
//            String host = "r-j6c2wlpopi33ufwut6pd.redis.rds.aliyuncs.com"; //internal
//            //String host = "r-j6c2wlpopi33ufwut6.redis.rds.aliyuncs.com"; //vpc
//            String password = "^";
////          单节点模型
//            //pool = new JedisPool(config, host, 6379, 3000, password);
//            //jedis = pool.getResource();
////          集群模式
//            Set<HostAndPort> nodes = new HashSet<>();
//            nodes.add(new HostAndPort(host, 6379));
//            this.jedis = new JedisCluster(nodes, 10000, 10000, 100, password, config);
//
//        }catch (Exception ex){
//            ex.printStackTrace();
//        }
//    }
//
//    private String ResponseErrorMsg(String msg) {
//        return "{\"error\":\"true\", \"message\":\"" + msg +"\"}";
//    }
//
//
//    /**
//     * 主程序
//     * @param input-json格式
//     * @return
//     */
//    public String Process(String input) {
//        System.out.println("input:"+input);
//        if (input == null || input.length() == 0) {
//            throw new RuntimeException(ResponseErrorMsg("input should not be empty"));
//        }
//
//
//        String gameId = "10000176";
//        //实时特征只配了10000100
//        String accId = "7b78fd8ac2bb36662f324fad7149900c";
//
//        if(this.jedis==null){
//            System.out.println("igraph not found!");
////            output.put("bizCode", 400);
////            output.put("bizMessage", "暂未支持该游戏");
//        }else {
//            try {
////                Long publishTimeL = Long.parseLong(publishTime);
////                Long ts = null;
////                                    Long ts = Long.parseLong(jedis.get("ts"));
////                                    int vipLv = Integer.parseInt(jedis.get("vipLv"));
//
//                //sim_cnt
//
//                //String[] old_chats = this.jedis.get(gameId + "_" + accId).split("\n");
//                String[] old_chats = this.jedis.get("10000176_17400a5c9fa7556dd4e3a962e54e2551").split("\n");
//                //LevenshteinDistance ld = new LevenshteinDistance();
//                System.out.println("======查询结果======");
//                for (String old_chat:old_chats){
//                    System.out.println(old_chat);
////                    String[] info = old_chat.split("\t");
////                    ts = Long.parseLong(info[0]);
////                    double levenshteinDistance = ld.LevenshteinDistancePercent(chat, info[1]);
////                    if(ts<publishTimeL && levenshteinDistance>=sim){
////                        sim_cnt ++;
////                        //System.out.println("判断相似");
////                    }
//                }
////                                    if(ts>=publishTimeL) {
////                                        sim_cnt=(sim_cnt-1<0)?sim_cnt:(sim_cnt-1);
////                                        //convertFeature = rpn4rt.featuresGenerator(igraph_kv,convertFeature,w2v_cluster,py2v_cluster,gameId);
////                                    }
//            }catch (Exception e){
//                e.printStackTrace();
//            }
//
////            output.put("bizCode", 200);
////            output.put("bizMessage", "");
//        }
//        return "testResult";
//    }
//
//
//    public static void main(String[] args) {
//        redis_hk_test pred = new redis_hk_test("", "");
//        pred.Load();
////        String input = "{\"accountId\":\"7b78fd8ac2bb36662f324fad7149900c\",\"content\":\"本盟賴群組已增設歡迎各路兄弟入群共同商討未來決策 httpslinemeRtig8VOqe94L\",\"gameId\":10000176,\"serverId\":\"S1\",\"roleId\":\"R6\",\"publishTime\":1617244334000}";
//        //String input = "{\"accountId\":\"7b78fd8ac2bb36662f324fad7149900c\",\"content\":\"各位在攻打码头386700前所有指令将在盟频想告请各位注意盟频 攻打386700码 头后请各位到自己的队频道管理员将会带领大家下一步动作 萧关队管理员为盟主咖啡茶酒 月支队管理员为副盟主续战天下 码头队管理员为两位指挥官细细粒Aqua) 各位加油\",\"gameId\":10000176,\"serverId\":\"S1\",\"roleId\":\"R6\",\"publishTime\":1617275911000}";
////        String input = "[{\"accountId\":1000015,\"content\":\"没事没事 你先加帮主vx吧 就说白细胞就行\"}," +
////                "{\"accountId\":1000015,\"content\":\"310ui_hyper_share_pos407;-63;20;80大荒古碑-6380\"}," +
////                "{\"accountId\":1000015,\"content\":\"[好友締交]\\n李滷味已與主公結爲好友\",\"gameId\":1000015,\"serverId\":\"S1\",\"roleId\":\"R6\",\"publishTime\":1532448012000}," +
////                "{\"accountId\":1000015,\"content\":\"加好友\",\"gameId\":100027,\"serverId\":\"S1\",\"roleId\":\"R6\",\"publishTime\":1532448012000}]";//
//        String result = pred.Process("====test start====");
//        //System.out.println(result);
//        System.out.println(0-1<0?0:0-1);
//    }
//}
